import { lazy } from "react";
import { Navigate, useRoutes } from 'react-router-dom'
const Home = lazy(() => import('../pages/home/Index'))
const Login = lazy(() => import('../pages/login/Index'))
const MainLayout = lazy(() => import('../pages/mainLayout/Index'))
const My = lazy(() => import('../pages/my/Index'))

//路由表
export const routes = [
    {
        path: '/',
        element: <Navigate to='/mainLayout/home'></Navigate>
    },
    {
        path: '/mainLayout',
        element: <MainLayout></MainLayout>,
        children: [
            {
                path: '/mainLayout/home',
                element: <Home></Home>
            },
            {
                path: '/mainLayout/my',
                element: <My></My>
            }
        ]
    }
    , {
        path: '/login',
        element: <Login></Login>
    }
]
export const RouterView = () => {
    return useRoutes(routes)
}